using HKB.Common;
using System;
using System.Data;
using System.Web;
namespace HKB.Web
{
	public class AccountDetailsBll
	{
		private Conn conn = null;
		public AccountDetailsBll()
		{
			this.conn = Text.GetComponent<Conn>("conn", HttpContext.Current.CurrentHandler);
		}
		public AccountDetailsBll(Conn _conn)
		{
			this.conn = _conn;
		}
		public DataTable SearchPayment(string wherestr)
		{
			return this.conn.GetDataTable("Select * From [HL_AccountDetails] " + wherestr + " Order By ID Desc");
		}
		public DataTable GetPaymentByUserID(int UserID)
		{
			return this.conn.GetDataTable("Select * From [HL_AccountDetails] Where UserID=" + UserID + " Order By ID Desc");
		}
		public int DeletePaymentByID(int ID)
		{
			return this.conn.Execute("delete From [HL_AccountDetails] Where ID=" + ID);
		}
		public void DeletePaymentByID(int ID, int UserID)
		{
			this.conn.Execute(string.Concat(new object[]
			{
				"delete From [HL_AccountDetails] Where ID=",
				ID,
				" and UserID=",
				UserID
			}));
		}
		public int AddAccountDetailsByTransaction(int UserID, decimal cmoney, decimal balance, int cType, string Remark)
		{
			string commandText = string.Concat(new object[]
			{
				"Insert Into HL_AccountDetails(UserID,cMoney,cType,uBalance,CreateTime,Remark) values(",
				UserID,
				",",
				cmoney,
				",",
				cType,
				",",
				balance,
				",getdate(),'",
				Remark,
				"')"
			});
			return this.conn.ExecuteTransaction(commandText);
		}
	}
}
